package edu.chl.jadetalk.admin.view;

import edu.chl.jadetalk.business.ImageManagerBeanLocal;
import edu.chl.jadetalk.business.UserManagerBeanLocal;
import edu.chl.jadetalk.core.Comment;
import edu.chl.jadetalk.core.Image;
import edu.chl.jadetalk.core.User;
import edu.chl.jadetalk.db.ICommentFacade;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author jesper
 */
@ManagedBean
@RequestScoped
public class ConsoleBackingBean {
    @EJB
    private ImageManagerBeanLocal imageManagerBean;
    @EJB
    private ICommentFacade commentFacade;
    
    @EJB
    private UserManagerBeanLocal userManagerBean;

    
    
    
    /** Creates a new instance of ConsoleBackingBean */
    public ConsoleBackingBean() {
    }
    
    //Get a list of users - their status and so on
    public List<User> getActiveUsers(){
        //TODO:Replace with Facade call.
//        User u1 = new User();
//        User u2 = new User();
//        
//        u1.setEmail("Email1");
//        u1.setPassword("Ahaha");
//        u1.setUsername("User1");
//        
//        u2.setEmail("Email2");
//        u2.setPassword("Ahaha");
//        u2.setUsername("User2");
//        
//        ArrayList<User> list = new ArrayList<User>();
//        list.add(u1);
//        list.add(u2);
//        return list;
        return userManagerBean.listUsers();
    }
    
    public List<Image> getNewImages(){
        //TODO:Replace with Facade call.
//        Image image1 = new Image();
//        image1.setImageLocation("url");
//        image1.setId(123l);
//        image1.setUser(getActiveUsers().get(0));
//        
//        List<Image> list = new ArrayList<Image>();
//        list.add(image1);
//        return list;
        return imageManagerBean.listImages();
    }
    
    public List<Comment> getNewcomments(){
        //TODO:Replace with Facade call.
//        Comment comment = new Comment();
//        comment.setCommentText("hello hello hello");
//        ArrayList<Comment> list = new ArrayList<Comment>();
//        list.add(comment);
//        return list;
        return commentFacade.findAll();
    }
    
    public String getUserAttName(){
        return "usrrattr";
    }
    
    public String getCommentAttName(){
        return "usccasttr";
    }
    
    public String getImageAttName(){
        return "imggg";
    }
}
